﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using ChangeHope.Common;
using System.Data;
using System.Text.RegularExpressions;

namespace YXShop.TemplateAction
{
    public partial class LabelParse
    {
        /// <summary>
        /// 商品列表
        /// </summary>
        /// <returns></returns>
        public string ProductList()
        {
            string mystyle = this.Label_Inserted;
            string str_ShowMode = this.GetParamValue("YX:ShowMode");//显示模式
            string str_ShowState = this.GetParamValue("YX:ShowState");//显示状态
            string str_ShowIdentifier = this.GetParamValue("YX:ShowIdentifier");////显示方式
            string str_CompositorType = this.GetParamValue("YX:CompositorType");//是否排序
            string str_CompositorField = this.GetParamValue("YX:CompositorField");//排序字段
            string str_ShowRows = this.GetParamValue("YX:ShowRows");//显示行数
            string str_ShowColumns = this.GetParamValue("YX:ShowColumns");//显示列数
            string NameCharacter = this.GetParamValue("YX:NameCharacter");//名称长度
            string str_WhetherPagination = this.GetParamValue("YX:WhetherPagination");//是否分页
            string Showhome = this.GetParamValue("YX:Showhome");//每页显示记录条数
            string str_TempletLayout = this.GetParamValue("YX:TempletLayout");//布局方式
            string WhetherOmit = this.GetParamValue("YX:WhetherOmit");//是否省略
            string ContentCharacter = this.GetParamValue("YX:ContentCharacter");//内容长度
            string IsStoreLabel = this.GetParamValue("YX:IsStoreLabel");//是否是店铺标签
            string str_SpecialModule = this.GetParamValue("YX:SpecialModule");
            string ProductClassId = this.GetParamValue("YX:ProductClassId");
            string order = "";
            string Comd = " 1=1 ";//条件

            StringBuilder Shtml = new StringBuilder();
            #region 查询参数
            Comd = " and pro_Audit=1";
            #region 显示模式
            if (!string.IsNullOrEmpty(str_ShowMode))//显示模式
            {
                switch (str_ShowMode)
                {
                    case "0":
                        Comd += "";
                        break;
                    case "1":
                        string pid = StringHelper.InputTexts(System.Web.HttpContext.Current.Request.QueryString["q_cid"]);
                        if (!string.IsNullOrEmpty(pid))
                        {
                            if (ValidateHelper.IsNumber(pid))
                            {
                                Comd += " and cid in (" + YXShop.TemplateAction.Common.CodStr(pid.ToString()) + ")";
                            }
                        }
                        break;
                    case "2":
                        string bid = StringHelper.InputTexts(System.Web.HttpContext.Current.Request.QueryString["q_bid"]);
                        if (!string.IsNullOrEmpty(bid))
                        {
                            if (ValidateHelper.IsNumber(bid))
                            {
                                Comd += " and pro_BrandID=" + bid + "";
                            }
                        }
                        break;
                    case "3":
                        string StateID = StringHelper.InputTexts(System.Web.HttpContext.Current.Request.QueryString["q_stateid"]);
                        if (!string.IsNullOrEmpty(StateID))
                        {
                            if (ValidateHelper.IsNumber(StateID))
                            {
                                Comd += " and " + "Substring(pro_State, " + StateID + ", 1) = 1";
                            }
                        }
                        break;
                    case "4":
                        string Pakeyword = ChangeHope.WebPage.PageRequest.GetQueryString("q_prokey");
                        if (Pakeyword != null && Pakeyword != string.Empty)
                        {
                            string keyword = StringHelper.InputTexts(Pakeyword);//关键字
                            if (!string.IsNullOrEmpty(keyword))
                            {
                                Comd += " and (pro_Name like '%" + keyword + "%' or pro_Content like '%" + keyword + "%' or pro_Synopsis like '%" + keyword + "%')";
                            }
                        }
                        string ProName = ChangeHope.WebPage.PageRequest.GetQueryString("q_proname");
                        if (ProName != string.Empty && ProName != null)
                        {
                            ProName = StringHelper.InputTexts(ProName);
                            if (!string.IsNullOrEmpty(ProName))
                            {
                                Comd += " and pro_Name like '%" + ProName + "%'";
                            }
                        }
                        string ProClassID = ChangeHope.WebPage.PageRequest.GetQueryString("q_proclassid");
                        if (ProClassID != string.Empty && ProClassID != null)
                        {

                            if (ValidateHelper.IsNumber(ProClassID))
                            {
                                Comd += " and cid in (" + YXShop.TemplateAction.Common.CodStr(ProClassID.ToString()) + ")";
                            }
                        }
                        string ProBrandID = ChangeHope.WebPage.PageRequest.GetQueryString("q_probrandid");
                        if (ProBrandID != string.Empty && ProBrandID != null)
                        {

                            if (ValidateHelper.IsNumber(ProBrandID))
                            {
                                Comd += " and pro_BrandID=" + ProBrandID + "";
                            }
                        }
                        string ProPrice1 = ChangeHope.WebPage.PageRequest.GetQueryString("q_proprice1");
                        string ProPrice2 = ChangeHope.WebPage.PageRequest.GetQueryString("q_proprice2");
                        if (ProPrice1 != string.Empty && ProPrice1 != null)
                        {
                            ProPrice1 = StringHelper.InputTexts(ProPrice1);

                            if (ProPrice1 != string.Empty && ProPrice1 != null && ProPrice2 != string.Empty && ProPrice2 != null)
                            {
                                ProPrice2 = StringHelper.InputTexts(ProPrice2);
                                Comd += " and pro_ShopPrice  between " + ProPrice1 + " and " + ProPrice2 + "";
                            }
                            else if (!string.IsNullOrEmpty(ProPrice1))
                            {
                                Comd += " and pro_ShopPrice =" + ProPrice1 + "";
                            }
                        }
                        string Attribute = ChangeHope.WebPage.PageRequest.GetQueryString("q_attribute");
                        if (Attribute != string.Empty && Attribute != null)
                        {
                            Attribute = StringHelper.InputTexts(Attribute);
                            if (ValidateHelper.IsNumber(Attribute))
                            {
                                Comd += " and " + "Substring(pro_State, " + Attribute + ", 1) = 1";
                            }
                        }
                        string ProContent = ChangeHope.WebPage.PageRequest.GetQueryString("q_procontent");
                        if (ProContent != string.Empty && ProContent != null)
                        {
                            ProContent = StringHelper.InputTexts(ProContent);
                            if (!string.IsNullOrEmpty(ProContent))
                            {
                                Comd += " and pro_Synopsis like '%" + ProContent + "%'";
                            }
                        }
                        string ProNO = ChangeHope.WebPage.PageRequest.GetQueryString("q_prono");
                        if (ProNO != string.Empty && ProNO != null)
                        {
                            ProNO = StringHelper.InputTexts(ProNO);
                            if (!string.IsNullOrEmpty(ProNO))
                            {
                                Comd += " and pro_NO = '" + ProNO + "'";
                            }
                        }
                        break;
                    case "5":
                        string compare1 = HttpContext.Current.Request.QueryString["s1"];
                        string compare2 = HttpContext.Current.Request.QueryString["s2"];
                        string compare3 = HttpContext.Current.Request.QueryString["s3"];
                        string compare = string.Empty;
                        if (compare1 != string.Empty && compare1 != null)
                        {
                            compare1 = StringHelper.InputTexts(compare1);
                            if (!string.IsNullOrEmpty(compare1))
                            {
                                if (!string.IsNullOrEmpty(compare))
                                {
                                    compare += "," + compare1;
                                }
                                else
                                {
                                    compare = compare1;
                                }
                            }
                        }
                        if (compare3 != string.Empty && compare3 != null)
                        {
                            compare3 = StringHelper.InputTexts(compare3);
                            if (!string.IsNullOrEmpty(compare3))
                            {
                                if (!string.IsNullOrEmpty(compare))
                                {
                                    compare += "," + compare3;
                                }
                                else
                                {
                                    compare = compare3;
                                }
                            }
                        }
                        if (compare2 != string.Empty && compare2 != null)
                        {
                            compare2 = StringHelper.InputTexts(compare2);
                            if (!string.IsNullOrEmpty(compare2))
                            {
                                if (!string.IsNullOrEmpty(compare))
                                {
                                    compare += "," + compare2;
                                }
                                else
                                {
                                    compare = compare2;
                                }
                            }
                        }
                        if (!string.IsNullOrEmpty(compare))
                        {
                            Comd += " and Pro_ID in (" + compare + ")";
                        }
                        break;
                    case "6":
                        if (ChangeHope.Common.ValidateHelper.IsNumber(ProductClassId))
                        {
                            Comd += " and cid in (" + YXShop.TemplateAction.Common.CodStr(ProductClassId) + ")";
                        }
                        break;
                    default:
                        break;
                }
            }
            #endregion

            if (IsStoreLabel == "1")
            {
                string StoreId = ChangeHope.WebPage.PageRequest.GetQueryString("UserId");
                if (StoreId != "")
                {
                    Comd += " and pro_PutoutType=1 and pro_PutoutID=" + StoreId;
                }
            }

            string property = ChangeHope.WebPage.PageRequest.GetQueryString("q_property");
            if (property != "")
            {
                string[] strProperty = property.Split(',');
                string propertyV = "";
                foreach (string pv in strProperty)
                {
                    string proId = pv.Substring(0, pv.IndexOf("_"));
                    string proValue = pv.Substring(pv.IndexOf("_") + 1, pv.Length - pv.IndexOf("_") - 1);
                    propertyV += "'%" + proId + "va_space%" + proValue + "%gro_space'";
                }
                Comd += " and like " + propertyV + "";

            }
            string brandId = ChangeHope.WebPage.PageRequest.GetQueryString("q_productbrand");
            if (brandId != "")
            {
                Comd += " and pro_BrandID=" + brandId + "";
            }

            if (!string.IsNullOrEmpty(str_ShowState) && ValidateHelper.IsNumber(str_ShowState))
            {
                if (str_ShowState != "0")
                {
                    Comd += " and Substring(Pro_State," + str_ShowState + ",1)=1";
                }

            }

            if (!string.IsNullOrEmpty(Showhome) && ValidateHelper.IsNumber(Showhome))//首页显示
            {
                if ((str_ShowState != "0") && (Showhome == "1"))
                {
                    Comd += " and Substring(Pro_State,11,1)=" + Showhome + "";
                }
            }
            if (!string.IsNullOrEmpty(Common.ProvinceStr("pro_Area")))
            {
                Comd += " and " + Common.ProvinceStr("pro_Area") + "";
            }
            if (!string.IsNullOrEmpty(str_ShowIdentifier) && ChangeHope.Common.ValidateHelper.IsNumber(str_ShowIdentifier))
            {
                Comd += " and Substring(Pro_Designation," + str_ShowIdentifier + ",1)=1";
                switch (str_ShowIdentifier)
                {
                    case "3":
                        Comd += " and pro_ID in (SELECT [productid] FROM [yxs_productintegratepurchase])";
                        break;
                    case "5":
                        Comd += " and pro_ID in (SELECT [productid] FROM [yxs_productauction])";
                        break;
                    case "7":
                        Comd += " and pro_ID in (SELECT [productid] FROM [yxs_ordercard])";
                        break;
                }
            }
            Comd += " and getdate()>=pro_AutoUp  and getdate()<pro_AutoDown";
            switch (str_SpecialModule)
            {
                case "1":
                    order = " [order by] pro_SaleNum desc";
                    break;
                default:
                    if (!string.IsNullOrEmpty(str_CompositorType))
                    {
                        string Field = "";
                        if (HttpContext.Current.Request["Link"] != null)
                        {
                            Field = HttpContext.Current.Request["Link"].ToString();
                        }
                        else
                        {
                            if (!string.IsNullOrEmpty(str_CompositorField))
                            {
                                Field = str_CompositorField;
                            }
                        }

                        if (HttpContext.Current.Request.QueryString["q_Sort"] != null && HttpContext.Current.Request.QueryString["q_Sort"] != string.Empty)
                        {
                            string Ord = StringHelper.InputTexts(HttpContext.Current.Request.QueryString["q_Sort"].ToString());
                            if (str_CompositorType == "0")
                            {
                                order = " [order by] " + Ord + " asc";
                            }
                            else if (str_CompositorType == "1")
                            {
                                order = " [order by] " + Ord + " Desc";
                            }
                        }
                        else
                        {
                            if (str_CompositorType == "0")
                            {
                                order = " [order by] " + Field + " asc";
                            }
                            else if (str_CompositorType == "1")
                            {
                                order = " [order by] " + Field + " desc";
                            }
                        }
                    }
                    break;
            }

            if (string.IsNullOrEmpty(str_ShowRows) && ValidateHelper.IsNumber(str_ShowRows))
            {
                str_ShowRows = "1";
            }
            if (string.IsNullOrEmpty(str_ShowColumns) && ValidateHelper.IsNumber(str_ShowColumns))
            {
                str_ShowColumns = "1";
            }
            int pagesize = Convert.ToInt32(str_ShowRows) * Convert.ToInt32(str_ShowColumns);

            YXShop.BLL.Product.ProductInfo bll = new YXShop.BLL.Product.ProductInfo();

            #endregion

            ChangeHope.DataBase.DataByPage dataPage = bll.GetList(order, pagesize, Comd);
            int itemcount = 0;
            if (dataPage.DataReader != null)
            {
                YXShop.Common.SysParameter sp = new YXShop.Common.SysParameter();

                if (!string.IsNullOrEmpty(mystyle))
                {
                    string pattern = @"\{\#[\s\S]*?\#\}";
                    string tempfinallyconent = mystyle;
                    StringBuilder GetTemp = new StringBuilder();
                    MatchCollection macths = Regex.Matches(tempfinallyconent, pattern);
                    string Str_Tag = "";
                    string temptag = "";
                    foreach (Match macth in macths)
                    {
                        temptag = macth.ToString();
                        int templength = temptag.ToString().IndexOf("{#") + 2;
                        int templength2 = temptag.ToString().IndexOf("#}");
                        if (temptag.ToString().Substring(templength, templength2 - templength).ToString() != null)
                        {
                            Str_Tag = temptag.ToString().Substring(templength, templength2 - templength);
                        }
                    }

                    StringBuilder content = new StringBuilder();

                    while (dataPage.DataReader.Read())
                    {
                        string strContent = string.Empty;
                        if (Str_Tag != "")
                        {
                            strContent = Str_Tag;
                        }
                        else
                        {
                            strContent = mystyle;
                        }
                        itemcount++;
                        //替换标签
                        #region 商品属性参数
                        double price = Convert.ToDouble(dataPage.DataReader["pro_ShopPrice"].ToString());
                        string memberPrice = dataPage.DataReader["pro_RatingDiscount"].ToString();
                        string specificationValue = "";
                        int productStock = Convert.ToInt32(dataPage.DataReader["pro_Stock"].ToString());
                        if (!string.IsNullOrEmpty(dataPage.DataReader["pro_Specifications"].ToString()))
                        {
                            YXShop.BLL.Product.ProductSpecification proSpe = new YXShop.BLL.Product.ProductSpecification();
                            List<YXShop.Model.Product.ProductSpecification> proSpeList = proSpe.GetSpecification(Convert.ToInt32(dataPage.DataReader["pro_ID"].ToString()));
                            if (proSpeList.Count > 0)
                            {
                                price = Convert.ToDouble(proSpeList[0].SalePrice);
                                memberPrice = proSpeList[0].MemberPrice;
                                specificationValue = proSpeList[0].Specifications;
                                productStock = proSpeList[0].ProductStock;
                            }
                        }
                        if (HttpContext.Current.Session["MemberID"] != null && !string.IsNullOrEmpty(memberPrice.Trim()))
                        {
                            price = YXShop.Common.ProductInfo.DiscountedPrice(int.Parse(HttpContext.Current.Session["MemberID"].ToString()), price, memberPrice);
                        }
                        int ContentCharacterNu = 30, NameCharacterNu = 10;
                        if (!string.IsNullOrEmpty(ContentCharacter) && ChangeHope.Common.ValidateHelper.IsNumber(ContentCharacter))
                        {
                            ContentCharacterNu = Convert.ToInt32(ContentCharacter);
                        }
                        if (!string.IsNullOrEmpty(NameCharacter) && ValidateHelper.IsNumber(NameCharacter))
                        {
                            NameCharacterNu = Convert.ToInt32(NameCharacter);
                        }
                        string Ellipsis = "...";
                        if (WhetherOmit == "False")
                        {
                            Ellipsis = "";
                        }

                        if (strContent.Contains("[#Product_Name]"))
                        {
                            string specVa = "";
                            if (specificationValue != "")
                            {
                                specVa = "&nbsp;&nbsp;" + specificationValue + "";
                            }
                            //strContent = strContent.Replace("[#Product_Name]", "<span title='" + dataPage.DataReader["pro_Name"].ToString() + "" + specVa + "'>" + ChangeHope.Common.StringHelper.SubStringAndAppend(dataPage.DataReader["pro_Name"].ToString(), NameCharacterNu, Ellipsis) + "</span>");//商品名称
                            strContent = strContent.Replace("[#Product_Name]", ChangeHope.Common.StringHelper.SubStringAndAppend(dataPage.DataReader["pro_Name"].ToString(), NameCharacterNu, Ellipsis));//商品名称
                        }
                        if (strContent.Contains("[#Product_No]"))
                        {
                            strContent = strContent.Replace("[#Product_No]", dataPage.DataReader["pro_NO"].ToString());
                        }

                        if (strContent.Contains("[#Product_Key]"))
                        {
                            if (dataPage.DataReader["pro_KeyWord"].ToString() != null)
                            {

                                strContent = strContent.Replace("[#Product_Key]", dataPage.DataReader["pro_KeyWord"].ToString());//关键字
                            }
                            else
                            {
                                strContent = strContent.Replace("[#Product_Key]", "");//关键字
                            }
                        }
                        if (strContent.Contains("[#Product_PickDownTime]"))
                        {
                            if (dataPage.DataReader["pro_AutoDown"].ToString() != null)
                            {

                                strContent = strContent.Replace("[#Product_PickDownTime]", dataPage.DataReader["pro_AutoDown"].ToString());//下架时间
                            }
                            else
                            {
                                strContent = strContent.Replace("[#Product_PickDownTime]", "");//下架时间
                            }
                        }
                        if (strContent.Contains("[#Product_MeasureUnit]"))
                        {
                            if (dataPage.DataReader["pro_Unit"].ToString() != null && dataPage.DataReader["pro_Unit"].ToString() != "0")
                            {

                                strContent = strContent.Replace("[#Product_MeasureUnit]", dataPage.DataReader["pro_Unit"].ToString());//商品单位
                            }
                            else
                            {
                                strContent = strContent.Replace("[#Product_MeasureUnit]", "");//商品单位
                            }
                        }
                        if (strContent.Contains("[#Product_Introduction]"))
                        {
                            if (dataPage.DataReader["pro_Synopsis"].ToString() != null)
                            {
                                strContent = strContent.Replace("[#Product_Introduction]", "" + ChangeHope.Common.StringHelper.SubStringAndAppend(dataPage.DataReader["pro_Synopsis"].ToString(), ContentCharacterNu, Ellipsis) + "");//商品简介
                            }
                            else
                            {
                                strContent = strContent.Replace("[#Product_Introduction]", "");//商品简介
                            }
                        }
                        if (strContent.Contains("[#Product_ShopPrice]"))
                        {
                            if (dataPage.DataReader["pro_ShopPrice"].ToString() != null)
                            {
                                strContent = strContent.Replace("[#Product_ShopPrice]", price.ToString("f2"));//商品商城价
                            }
                            else
                            {
                                strContent = strContent.Replace("[#Product_ShopPrice]", "0");//商品商城价
                            }
                        }
                        if (strContent.Contains("[#Product_MarketPrice]"))
                        {
                            if (dataPage.DataReader["pro_MarketPrice"].ToString() != null)
                            {
                                strContent = strContent.Replace("[#Product_MarketPrice]", dataPage.DataReader["pro_MarketPrice"].ToString());//商品市场价
                            }
                            else
                            {
                                strContent = strContent.Replace("[#Product_MarketPrice]", "");//商品市场价
                            }
                        }
                        if (strContent.Contains("[#Product_Spread]"))
                        {
                            double marketPrice = Convert.ToDouble(dataPage.DataReader["pro_MarketPrice"].ToString());
                            strContent = strContent.Replace("[#Product_Spread]", (marketPrice - price).ToString("f2"));
                        }
                        if (strContent.Contains("[#Product_Thumbnails]"))
                        {
                            if ((dataPage.DataReader["pro_Thumbnail"].ToString() != null) && (dataPage.DataReader["pro_Thumbnail"].ToString() != ""))
                            {
                                strContent = strContent.Replace("[#Product_Thumbnails]", sp.DummyPaht + dataPage.DataReader["pro_Thumbnail"].ToString());//商品缩略图
                            }
                            else
                            {
                                strContent = strContent.Replace("[#Product_Thumbnails]", sp.DummyPaht + "images/NaughtImages.gif");//商品缩略图

                            }
                        }
                        if (strContent.Contains("[#Product_Bigmap]"))
                        {
                            if ((dataPage.DataReader["pro_Images"].ToString() != null) && (dataPage.DataReader["pro_Images"].ToString() != ""))
                            {
                                strContent = strContent.Replace("[#Product_Bigmap]", sp.DummyPaht + dataPage.DataReader["pro_Images"].ToString());//商品大图
                            }
                            else
                            {
                                strContent = strContent.Replace("[#Product_Bigmap]", sp.DummyPaht + "images/NaughtImages.gif");//商品大图

                            }
                        }

                        if (strContent.Contains("[#Product_Weight]"))
                        {
                            if (dataPage.DataReader["pro_Weight"].ToString() != null)
                            {
                                strContent = strContent.Replace("[#Product_Weight]", dataPage.DataReader["pro_Weight"].ToString());//商品重量
                            }
                            else
                            {
                                strContent = strContent.Replace("[#Product_Weight]", "");//商品重量

                            }
                            if (strContent.Contains("[#Product_Units]"))
                            {
                                if (dataPage.DataReader["pro_WeightUnit"].ToString() != null)
                                {
                                    string weightUnit = dataPage.DataReader["pro_WeightUnit"].ToString() == "1" ? "千克" : "克";
                                    strContent = strContent.Replace("[#Product_Units]", weightUnit);//商品重量单位
                                }
                                else
                                {
                                    strContent = strContent.Replace("[#Product_Units]", "");//商品重量单位

                                }
                            }
                        }

                        if (strContent.Contains("[#Product_Stock]"))
                        {
                            if (dataPage.DataReader["pro_Stock"].ToString() != null)
                            {
                                strContent = strContent.Replace("[#Product_Stock]", productStock.ToString());//商品库存
                            }
                            else
                            {
                                strContent = strContent.Replace("[#Product_Stock]", "");//商品库存

                            }
                        }
                        if (strContent.Contains("[#Product_ShelvesCount]"))
                        {
                            if (dataPage.DataReader["pro_AuditCount"].ToString() != null)
                            {
                                strContent = strContent.Replace("[#Product_ShelvesCount]", dataPage.DataReader["pro_AuditCount"].ToString());//商品上架数量
                            }
                            else
                            {
                                strContent = strContent.Replace("[#Product_ShelvesCount]", "");//商品上架数量

                            }
                        }
                        string SellModel = "";
                        //商品出售方式（1：只能使用现金购买；2：只能使用积分购买；3：现金或积分均可）
                        if (dataPage.DataReader["pro_SaleType"].ToString() == "1")
                        {
                            SellModel = "现金购买";

                        }
                        else if (dataPage.DataReader["pro_SaleType"].ToString() == "2")
                        {
                            SellModel = "积分购买";
                        }
                        else if (dataPage.DataReader["pro_SaleType"].ToString() == "3")
                        {
                            SellModel = "现金或积分均可";
                        }
                        if (strContent.Contains("[#Product_SellWay]"))
                        {
                            strContent = strContent.Replace("[#Product_SellWay]", SellModel);
                        }
                        #endregion

                        #region 点卡
                        if (str_ShowIdentifier == "7")
                        {
                            YXShop.BLL.OrderCard.OrderCardInfo oribll = new YXShop.BLL.OrderCard.OrderCardInfo();
                            YXShop.Model.OrderCard.OrderCardInfo orimodel = oribll.GetModelID(Convert.ToInt32(dataPage.DataReader["pro_ID"].ToString()));
                            string FaceValue = string.Empty;
                            string Price = string.Empty;
                            string Point = string.Empty;
                            string Unit = string.Empty;
                            string ExpirationDate = string.Empty;
                            string BusinessAgent = string.Empty;
                            if (orimodel != null)
                            {
                                FaceValue = orimodel.FaceValue.ToString();
                                Price = orimodel.Price.ToString();
                                Point = orimodel.Point;
                                Unit = orimodel.Unit;
                                ExpirationDate = orimodel.ExpirationDate.ToString();
                                BusinessAgent = orimodel.BusinessAgent;
                            }
                            if (strContent.Contains("[#card_FaceValue]"))
                            {
                                strContent = strContent.Replace("[#card_FaceValue]", FaceValue);
                            }
                            if (strContent.Contains("[#card_Price]"))
                            {
                                strContent = strContent.Replace("[#card_Price]", Price);
                            }
                            if (strContent.Contains("[#card_Point]"))
                            {
                                strContent = strContent.Replace("[#card_Point]", Point);
                            }
                            if (strContent.Contains("[#card_Unit]"))
                            {
                                strContent = strContent.Replace("[#card_Unit]", Unit);
                            }
                            if (strContent.Contains("[#card_ExpirationDate]"))
                            {
                                strContent = strContent.Replace("[#card_ExpirationDate]", ExpirationDate);
                            }
                            if (strContent.Contains("[#card_BusinessAgent]"))
                            {
                                strContent = strContent.Replace("[#card_BusinessAgent]", BusinessAgent);
                            }
                            orimodel = null;

                        }
                        #endregion

                        #region 团购
                        if (str_ShowIdentifier == "3")
                        {
                            YXShop.BLL.Product.Product_IntegratePurchas pipbll = new YXShop.BLL.Product.Product_IntegratePurchas();
                            YXShop.Model.Product.Product_IntegratePurchas pipmodel = pipbll.GetModelProductID(Convert.ToInt32(dataPage.DataReader["pro_ID"].ToString()));
                            string StartTime = string.Empty;
                            string EndTime = string.Empty;
                            string Deposit = string.Empty;
                            string BuyCount = string.Empty;
                            string DonateIntegral = string.Empty;
                            string PriceLevel = string.Empty;
                            string Description = string.Empty;
                            if (pipmodel != null)
                            {
                                StartTime = pipmodel.StartTime.ToString();
                                EndTime = pipmodel.EndTime.ToString();
                                Deposit = pipmodel.Deposit.ToString();
                                BuyCount = pipmodel.Count.ToString();
                                DonateIntegral = pipmodel.DonateIntegral.ToString();
                                string[] LadderCount = pipmodel.LadderCount.Split(',');
                                string[] LadderPrice = pipmodel.LadderPrice.Split(',');
                                string ProductUnit = "";
                                if (dataPage.DataReader["pro_Unit"].ToString() != "0")
                                {
                                    ProductUnit = dataPage.DataReader["pro_Unit"].ToString();
                                }
                                for (int l = 0; l < LadderCount.Length; l++)
                                {
                                    PriceLevel += "团购数量达到：" + LadderCount[l] + ProductUnit + "，享受价格为：" + LadderPrice[l] + "<br>";
                                }
                                Description = pipmodel.Description;

                            }
                            if (strContent.Contains("[#GroupBuy_StartTime]"))
                            {
                                strContent = strContent.Replace("[#GroupBuy_StartTime]", StartTime);

                            }
                            if (strContent.Contains("[#GroupBuy_EndTime]"))
                            {
                                strContent = strContent.Replace("[#GroupBuy_EndTime]", EndTime);
                            }
                            if (strContent.Contains("[#GroupBuy_Deposit]"))
                            {
                                strContent = strContent.Replace("[#GroupBuy_Deposit]", Deposit);
                            }
                            if (strContent.Contains("[#GroupBuy_BuyCount]"))
                            {
                                strContent = strContent.Replace("[#GroupBuy_BuyCount]", BuyCount);
                            }
                            if (strContent.Contains("[#GroupBuy_DonateIntegral]"))
                            {
                                strContent = strContent.Replace("[#GroupBuy_DonateIntegral]", DonateIntegral);
                            }
                            if (strContent.Contains("[#GroupBuy_PriceLevel]"))
                            {
                                strContent = strContent.Replace("[#GroupBuy_PriceLevel]", PriceLevel);
                            }
                            if (strContent.Contains("[#GroupBuy_Description]"))
                            {
                                strContent = strContent.Replace("[#GroupBuy_Description]", Description);
                            }
                        }
                        #endregion

                        #region 拍卖
                        if (str_ShowIdentifier == "5")
                        {
                            YXShop.BLL.Product.ProductAuction pabll = new YXShop.BLL.Product.ProductAuction();
                            YXShop.Model.Product.ProductAuction pamodel = pabll.GetModelProductID(Convert.ToInt32(dataPage.DataReader["pro_ID"].ToString()));
                            string AuctionName = string.Empty;
                            string StartTime = string.Empty;
                            string EndTime = string.Empty;
                            string Price = string.Empty;
                            string PriceRange = string.Empty;
                            string Deposit = string.Empty;
                            string Description = string.Empty;
                            if (pamodel != null)
                            {
                                AuctionName = pamodel.AuctionName;
                                StartTime = pamodel.StartTime.ToString();
                                EndTime = pamodel.EndTime.ToString();
                                Price = pamodel.Price.ToString();
                                PriceRange = pamodel.PriceRange.ToString();
                                Deposit = pamodel.Deposit.ToString();
                                Description = pamodel.Description;
                            }

                            if (strContent.Contains("[#Auction_Name]"))
                            {
                                strContent = strContent.Replace("[#Auction_Name]", AuctionName);
                            }
                            if (strContent.Contains("[#Auction_StartTime]"))
                            {
                                strContent = strContent.Replace("[#Auction_StartTime]", StartTime);
                            }
                            if (strContent.Contains("[#Auction_EndTime]"))
                            {
                                strContent = strContent.Replace("[#Auction_EndTime]", EndTime);
                            }
                            if (strContent.Contains("[#Auction_StartPrice]"))
                            {
                                strContent = strContent.Replace("[#Auction_StartPrice]", Price);
                            }
                            if (strContent.Contains("[#Auction_AddLevel]"))
                            {
                                strContent = strContent.Replace("[#Auction_AddLevel]", PriceRange);
                            }
                            if (strContent.Contains("[#Auction_Deposit]"))
                            {
                                strContent = strContent.Replace("[#Auction_Deposit]", Deposit);
                            }
                            if (strContent.Contains("[#Auction_Description]"))
                            {
                                strContent = strContent.Replace("[#Auction_Description]", Description);
                            }
                        }
                        #endregion

                        #region 操作方式
                        if (strContent.Contains("[#Option_Src]"))
                        {
                            strContent = strContent.Replace("[#Option_Src]", Common.UrlStr("productcontent", "q_productid=" + dataPage.DataReader["pro_ID"].ToString() + "", "product/"));
                        }
                        if (strContent.Contains("[#Option_GroupBuyURL]"))
                        {
                            strContent = strContent.Replace("[#Option_GroupBuyURL]", Common.UrlStr("product_groupbuy_content", "q_productid=" + dataPage.DataReader["pro_ID"].ToString() + "", "product/"));
                        }
                        if (strContent.Contains("[#Option_AuctionURL]"))
                        {
                            strContent = strContent.Replace("[#Option_AuctionURL]", Common.UrlStr("product_auction_content", "q_productid=" + dataPage.DataReader["pro_ID"].ToString() + "", "product/"));
                        }
                        if (strContent.Contains("[#Option_Buy]"))
                        {
                            if (productStock < 1)
                            {
                                strContent = strContent.Replace("[#Option_Buy]", "<img  src='" + sp.DummyPaht + sp.WebSiteTemplatePath + "/images/bottomWheelbarrow.gif' /><span style='COLOR: #666666;'><a href=\"#\">购买</a></span>");
                            }
                            else
                            {
                                strContent = strContent.Replace("[#Option_Buy]", "<img  src='" + sp.DummyPaht + sp.WebSiteTemplatePath + "/images/bottomWheelbarrow.gif' /><span style='COLOR: #666666;'><a href=\"" + Common.UrlStr("shoppingcart", "q_productid=" + dataPage.DataReader["pro_ID"].ToString() + ";q_proSpecification=" + specificationValue + "", "product/") + "\">购买</a></span>");
                            }
                        }
                        if (strContent.Contains("[#Option_Favorites]"))
                        {
                            strContent = strContent.Replace("[#Option_Favorites]", "<img  src='" + sp.DummyPaht + sp.WebSiteTemplatePath + "/images/sC.gif' /><span style='COLOR: #666666;'><a href=\"" + Common.UrlStr("collection", "q_productid=" + dataPage.DataReader["pro_ID"].ToString() + "", "filehandle/") + "\">收藏</a></span>");
                        }
                        if (strContent.Contains("[#Option_Comparison]"))
                        {
                            strContent = strContent.Replace("[#Option_Comparison]", "<img  src='" + sp.DummyPaht + sp.WebSiteTemplatePath + "/images/compare1.gif'  id=\"pcheck_131\" onclick=\"addToCompare(this," + dataPage.DataReader["pro_ID"].ToString() + ",'" + dataPage.DataReader["pro_Name"].ToString() + "')\"/><span style='COLOR: #666666;'><a href=\"javascript:addToCompare(this," + dataPage.DataReader["pro_ID"].ToString() + ",'" + dataPage.DataReader["pro_Name"].ToString() + "')\"  id=\"pcheck_131\" >比较</a></span>");

                        }
                        //图片路径
                        if (strContent.Contains("[#DummyPahtAndTemplatePaht]"))
                        {
                            strContent = strContent.Replace("[#DummyPahtAndTemplatePaht]", sp.DummyPaht + sp.WebSiteTemplatePath);
                        }
                        //购买链接
                        if (strContent.Contains("[#BuyUrl]"))
                        {
                            if (productStock < 1)
                            {
                                strContent = strContent.Replace("[#BuyUrl]", "#");
                            }
                            else
                            {
                                strContent = strContent.Replace("[#BuyUrl]", Common.UrlStr("shoppingcart", "q_productid=" + dataPage.DataReader["pro_ID"].ToString() + ";q_proSpecification=" + specificationValue + "", "product/"));
                            }
                        }
                        //收藏链接
                        if (strContent.Contains("[#CollectionUrl]"))
                        {
                            strContent = strContent.Replace("[#CollectionUrl]", Common.UrlStr("collection", "q_productid=" + dataPage.DataReader["pro_ID"].ToString() + "", "filehandle/"));
                        }
                        //比较
                        if (strContent.Contains("[#ComparisonUrl]"))
                        {
                            strContent = strContent.Replace("[#ComparisonUrl]", "javascript:addToCompare(this," + dataPage.DataReader["pro_ID"].ToString() + ",'" + dataPage.DataReader["pro_Name"].ToString() + "')");

                        }
                        #endregion


                        content.Append(strContent);
                        if (str_TempletLayout == "1")
                        {
                            if ((itemcount % Convert.ToInt32(str_ShowColumns)) == 0)
                            {
                                content.Append("</tr><tr>");
                            }
                            else
                            {
                                content.Append("</td><td>");
                            }
                        }

                    }

                    if (Str_Tag != "")
                    {
                        if (content.ToString() != string.Empty)
                        {
                            mystyle = mystyle.Replace(temptag, content.ToString());
                        }
                        else
                        {
                            mystyle = mystyle.Replace(temptag, "");
                        }
                        Shtml.Append(mystyle);
                    }
                    else
                    {
                        Shtml.Append(content.ToString());
                    }

                }
            }
            if (str_WhetherPagination == "0")
            {
                Shtml.Append(dataPage.ReceptionToolBar);

            }
            dataPage.Dispose();
            dataPage = null;
            if (str_TempletLayout == "1")
            {
                return "<table width='100%'>" + Shtml.ToString() + "</table>";
            }
            return Shtml.ToString();
        }


    }
}

